﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace Applay
{
    public class ValidationScope : IDisposable
    {
        private readonly Wrapper wrapper;
        private readonly IValidationState validationState;

        internal ValidationScope(Wrapper wrapper, IValidationState validationState)
        {
            Contract.Requires(wrapper != null);
            Contract.Requires(validationState != null);

            this.wrapper = wrapper;
            this.wrapper.ValidationScope = this;
            this.validationState = validationState;
        }

        public IValidationState ValidationState
        {
            get { return this.validationState; }
        }

        public void Dispose()
        {
            this.wrapper.ValidationScope = null;
        }
    }
}
